<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
<% String hello= "You are Logged in as "+(String)session.getAttribute("userName");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <link rel="stylesheet" href="css/user.css" type="text/css" />
        <title><%= hello%></title>
    </head>
    <body>
        <div id="wrap">
            <%  
            String project="project";
            String task="task";
            String form="form";
            String personalInfo="personal_info";
            String pageid=request.getParameter("pageid");
            String uname=(String)session.getAttribute("userName");
            String pass = request.getParameter("password");
            String emp_id=null;
            %>
            <% //connect to database and set emp_id to the session
            String query="select emp_id from login"+" where username='"+uname+"'";
            Connection db_conn = null;
            Statement statement = null;
            PreparedStatement pstmt;
            ResultSet rs;
            try{
            Class.forName("com.mysql.jdbc.Driver");
            String url= "jdbc:mysql://localhost:3306/db";
            db_conn = DriverManager.getConnection( url,"root", "root" );
            statement = db_conn.createStatement();  
            rs=statement.executeQuery(query);
            while (rs.next()) { // parse the results
            emp_id=rs.getString("emp_id");
            session.setAttribute("emp_id",emp_id);
            }
            db_conn.close();
            }
            catch(SQLException e){
            e.printStackTrace();
            out.println("sql not found");
            out.println(e);
            }
            catch(ClassNotFoundException e){
            e.printStackTrace();
            out.println(e);
            }
            %>
            
           <jsp:include page="user/header.jsp" />
            		
            <!-- content-wrap starts here -->
            <div id="content-wrap">		
                <img src="images/user/headerphoto.jpg" width="820" height="120" alt="headerphoto" class="no-border" />
                <div id="sidebar" >			
                    <!-- this file has the list of projects involved by the user -->				
                    <jsp:include page="user/projects_involved.jsp" />		
                    
                    <!-- this file has the list of tasks assigned to the user -->
                    <jsp:include page="user/tasks_assigned.jsp" />
                    
                    <!-- this file has the wise word of the day -->
                    <jsp:include page="user/wise_word.jsp" />				
                    
                </div>
                
                <div id="main">	
                    <!-- this file has the content of the main area -->
                    <% if(pageid.equals(project)){%>
                    <jsp:include page="user/projects_involved/projects_display.jsp" />
                    <% }else if(pageid.equals(task)){ %>
                    <jsp:include page="user/tasks_involved/tasks_display.jsp" >
                         <jsp:param name="ttid" value="0" />
                    </jsp:include>    
                <% }else if(pageid.equals(form)){ %>
                    <jsp:include page="user/uploads/upload_form.jsp" />
                <% }else if(pageid.equals(personalInfo)){ %>
                    <jsp:include page="user/personal info/personal_info.jsp" />    
                <% }else { %>
                    <jsp:include page="user/default.jsp" />
                <% }%>
            </div>	
            <div id="noticebar">
        	<!-- this file has the notice posted to him by the admin -->
		<jsp:include page="user/noticebar.jsp"/>
              
            </div>
		
     </div><!-- content-wrap ends here -->	

    <div id="footer">
   	 <jsp:include page="user/footer.jsp"/>
    </div>
</div><!-- wrap ends here -->
</body>
</html>
